#include <stdio.h>
#include <cstring>
	struct person
{
	char name[20];
	int cnt;	
}leader[3]={"a",0,"b",0,"c",0};
int main()
{
	struct person s;
	int max,k,t;
	for(int i=0;i<5;i++){
		scanf("%s",&s.name);
		for(int j=0;j<3;j++){
		if(strcmp(leader[j].name,s.name)==0){
		leader[j].cnt++;
		}
		}
	}
	max=leader[0].cnt;
	for(k=0;k<3;k++){
		if(leader[k].cnt>max){
			max=leader[k].cnt;
			t=k;
		}
	}
	printf("%s %d",leader[t].name,leader[t].cnt);
	
	return 0;
}
